package com.heima.feigins.fallback;


import com.heima.feigins.AdminFeign;
import com.heima.model.admin.pojos.AdChannel;
import com.heima.model.admin.pojos.AdSensitive;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.enums.AppHttpCodeEnum;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;

@Component("adminFeiginEallback")
@Slf4j
public class AdminFeiginFallback implements FallbackFactory<AdminFeign> {
    @Override
    public AdminFeign create(Throwable throwable) {
        return new AdminFeign() {
            @Override
            public ResponseResult<List<String>> selectAllSensitive() {
                log.error("远程服务调用admin微服务的查询敏感词方法，失败了");
                return ResponseResult.errorResult(AppHttpCodeEnum.REMOTE_SERVER_ERROR,"远程调用admin失败了");
            }

            @Override
            public ResponseResult<AdChannel> findOne(Integer id) {
                log.error("远程服务调用admin微服务的根据id查询频道信息，失败了");
                return ResponseResult.errorResult(AppHttpCodeEnum.REMOTE_SERVER_ERROR,"远程调用admin失败了");
            }
        };
    }
}
